package com.systemsjr.jrenterprise.invoice;

import javax.swing.JTable;
import javax.swing.table.TableColumnModel;

import com.systemsjr.jrenterprise.invoice.vo.InvoiceVO;
import com.systemsjr.jrenterprise.utils.ServiceUtils;
import com.systemsjr.jrlib.richclient.BaseItemTable;

public class InvoiceTable extends BaseItemTable<InvoiceVO> {

	public InvoiceTable() {
		super(new InvoiceVO[]{}, "invoiceTable", new String[]{
				"id",
				"invoiceDate",
				"total"
		});
	}
	
	@Override
	protected void configureTable(JTable table) {
		super.configureTable(table);
		TableColumnModel tcm = table.getColumnModel();
		tcm.getColumn(0).setPreferredWidth(50);
		tcm.getColumn(1).setPreferredWidth(50);
		tcm.getColumn(2).setPreferredWidth(30);
	}
	
	@Override
	protected Object[] getDefaultInitialData() {
		setInitialData(ServiceUtils.getInvoiceService().loadAll().toArray());
		return getInitialData();
	}

}
